﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using MSRI.HelperClasses;
using MSRI.TCPServices;
using System.Net.Sockets;
using System.IO;
using SmsServerClient;
using MSRI.DesktopAgent.CeRapi;

namespace WindowsFormsSMSServer
{
    public partial class Form1 : Form
    {
        public static readonly SimpleSMSServer.Connector SmsService = new SimpleSMSServer.Connector();
        private TcpSocketClass MySocket;

        public Form1()
        {
            short port = 3434;
            this.MySocket = new TcpSocketClass(IPAddress.Parse("127.0.0.1"), port);
            
            this.MySocket.MessageReceived += new TcpSocketClass.MessageReceivedDelegate(this.MySocket_MessageReceived);
            this.MySocket.Connected += new TcpSocketClass.ConnectedDelegate(this.MySocket_Connected);
            this.MySocket.Disconnected += new TcpSocketClass.DisconnectedDelegate(this.MySocket_Disconnected);
            this.MySocket.SmsReceived += new TcpSocketClass.SmsReceivedDelegate(this.MySocket_SmsReceived);
            this.MySocket.StartListener();
           
        }

        private void MySocket_Connected()
        {
            //this.ConnectionStatusUpdate("Connected via TCP");
        }

        private void MySocket_Disconnected(bool ShouldRestart)
        {
           
        }

        private void MySocket_MessageReceived(string Message)
        {

        }

        private void MySocket_SmsReceived(SmsClass Message)
        {
            Form1.SmsService.SendMessage(Message.Number, Message.Body);
        }
    }
}
